DicomObjects.COM.V8
In This Topic
    Import/Export DLLs
    In This Topic

    DicomObjects includes the facility to write your own DLLs for import and export of external image formats, and this topic explains how.
    There are two types of filter, those for memory formats, and those for files.  When importing from or exporting to a file, DicomObjects first check for an appropriate file specific DLL entry, but if this is not present, then an appropriate memory based entry will be used if available.  This process is applied before checking for intrinsic functions, so the internal JPEG and DIB/BMP routines may be over-ridden if necessary.

    In order for the appropriate DLL to be found, the <Type> to be handled should be created as a key under the correct DicomObjects registry path, and this must contain 2 values:

     


    The appropriate registry paths are:

     

    The functions to perform the export or export must be callable as standard DLL routines, and in C++, the declarations are:

    extern "C"
    _declspec(dllexport) void  __cdecl FileImportExportFunction

    (IDispatch * Image, 
    const char * Filename, 
    const char * Type,
    const VARIANT FAR& Info,
    char ** error)

    extern "C"
    _declspec(dllexport) OLE_HANDLE __cdecl ExportMemoryFunc(

    IDispatch * Image,
    const char * Type,
    const VARIANT FAR& Info,
    char ** error,
    long * len)

    extern "C"
    _declspec(dllexport)  void __cdecl ImportMemoryFunc(

    IDispatch * Image,
    OLE_HANDLE Handle,
    const char * Type,
    const VARIANT FAR& Info,
    char ** error)

     

    Image is the DicomImage being imported, and needs to be accessed through its standard properties and methods.  In practice, the DicomObjects type library would normally be #import’ed, and this parameter may become “struct IDicomImage * Image”.
    ExportMemoryFunc must return a global memory handle (cast to an OLE_HANDLE).  This will be deallocated either by the calling process (if called from MemoryExport) or by DicomObjects (if called from ArrayExport or FileExport). The length of the actual data with this memory block should be returned in len)

    ImportMemoryFunc is passed it’s data via the Handle parameter.  This memory block should be unaltered on return, i.e. if locked it should be unlocked again, and it should not be freed.
    Filename, Type and Info are passed directly from the corresponding Import or Export methods.
    Error initially points to a NULL pointer, but if an error occurs, then it should be set to point to a simple character string, containing an explanatory message, (which should be allocated on the heap, and will be cleared by DicomObjects)